package com.china08.yxyapi.repository.mg.huodong;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import com.china08.yxyapi.entity.mg.huodong.healthcompetition.YxyCompetitionStudent;

public interface YxyCompetitionStudentRepository extends MongoRepository<YxyCompetitionStudent, String> {
	/**
	 * 通过学生id查找答题学生
	 * 
	 * @param studentId
	 * @return
	 */
	YxyCompetitionStudent findTop1ByStudentId(String studentId);

	/**
	 * 当用户是家长时,查找该家长下哪个孩子最后答题
	 * 
	 * @param studentIds
	 * @return
	 */
	YxyCompetitionStudent findTop1ByStatusNotAndStudentIdInOrderByLastModifiedDateDesc(Integer status,
			List<String> studentIds);

	/**
	 * 得到参与答题的所有学生
	 * 
	 * @param i
	 * @return
	 */
	List<YxyCompetitionStudent> findBySchoolIdNotInAndStatus(List<String> ids, Integer i);

	/**
	 * 根据学校id得到参与答题的所有学生
	 * 
	 * @param i
	 * @param schoolId
	 * @return
	 */
	List<YxyCompetitionStudent> findByStatusAndSchoolId(Integer i, String schoolId);

	/**
	 * 分页查询根据schoolId
	 * 
	 * @param schoolId
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolId(String schoolId, Pageable pageable);

	/**
	 * 分页查询根据schoolId,status
	 * 
	 * @param schoolId
	 * @param status
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolIdAndStatus(String schoolId, Integer status, Pageable pageable);

	/**
	 * 分页查询根据schoolId,status,grade
	 * 
	 * @param schoolId
	 * @param status
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolIdAndStatusAndGrade(String schoolId, Integer status, String grade,
			Pageable pageable);

	/**
	 * 分页查询根据schoolId,status,grade,classId
	 * 
	 * @param schoolId
	 * @param status
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolIdAndStatusAndGradeAndClassId(String schoolId, Integer status, String grade,
			String classId, Pageable pageable);

	/**
	 * 分页查询根据schoolId,grade
	 * 
	 * @param schoolId
	 * @param status
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolIdAndGrade(String schoolId, String grade, Pageable pageable);

	/**
	 * 分页查询根据schoolId,grade,classId
	 * 
	 * @param schoolId
	 * @param status
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolIdAndGradeAndClassId(String schoolId, String grade, String classId,
			Pageable pageable);
	// *****************以下是未完成竞赛分页查询方法*******************************

	/**
	 * 分页查询根据schoolId,statusnot
	 * 
	 * @param schoolId
	 * @param status
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolIdAndStatusNot(String schoolId, Integer status, Pageable pageable);

	/**
	 * 分页查询根据schoolId,statusnot,grade
	 * 
	 * @param schoolId
	 * @param status
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolIdAndStatusNotAndGrade(String schoolId, Integer status, String grade,
			Pageable pageable);

	/**
	 * 分页查询根据schoolId,status,grade,classId
	 * 
	 * @param schoolId
	 * @param status
	 * @param pageable
	 * @return
	 */
	Page<YxyCompetitionStudent> findBySchoolIdAndStatusNotAndGradeAndClassId(String schoolId, Integer status,
			String grade, String classId, Pageable pageable);

	/**
	 * 根据status school stage查询
	 * 
	 * @param i
	 * @param school
	 * @param gradeName
	 * @return
	 */
	List<YxyCompetitionStudent> findByStatusAndSchoolIdAndStage(int i, String school, String gradeName);

	/**
	 * 根据status school stage class查询
	 * 
	 * @param i
	 * @param school
	 * @param gradeName
	 * @return
	 */
	List<YxyCompetitionStudent> findByStatusAndSchoolIdAndStageAndClassId(int i, String school, String gradeName,
			String classId);

	/**
	 * 根据status school grade class查询
	 * 
	 * @param i
	 * @param school
	 * @param gradeName
	 * @return
	 */
	List<YxyCompetitionStudent> findByStatusAndSchoolIdAndGradeAndClassId(int i, String school, String gradeName,
			String classId);

	/**
	 * 根据status school grade查询
	 * 
	 * @param i
	 * @param school
	 * @param gradeName
	 * @return
	 */
	List<YxyCompetitionStudent> findByStatusAndSchoolIdAndGrade(int i, String school, String gradeName);

}
